package pl.smath.expression;

import junit.framework.TestCase;
import pl.smath.parser.ExpressionParser;


public class TermTestCase extends TestCase {

	public void testTheSameFalse1(){
		ExpressionParser parser = new ExpressionParser();
			
		Term term1 = parser.parseText( "3" );
		Term term2 = parser.parseText( "2" );
		assertFalse(term1.isTheSame(term2));
	}

	public void testTheSameFalse2(){
		ExpressionParser parser = new ExpressionParser();
			
		Term term1 = parser.parseText( "x" );
		Term term2 = parser.parseText( "2" );
		assertFalse(term1.isTheSame(term2));
	}

	public void testTheSameFalse3(){
		ExpressionParser parser = new ExpressionParser();
			
		Term term1 = parser.parseText( "2*x" );
		Term term2 = parser.parseText( "3*x" );
		assertFalse(term1.isTheSame(term2));
	}

	public void testTheSameFalse4(){
		ExpressionParser parser = new ExpressionParser();
			
		Term term1 = parser.parseText( "x" );
		Term term2 = parser.parseText( "y" );
		assertFalse(term1.isTheSame(term2));
	}

	public void testTheSameNumeric(){
		ExpressionParser parser = new ExpressionParser();
			
		Term term1 = parser.parseText( "2" );
		Term term2 = parser.parseText( "2" );
		assertTrue(term1.isTheSame(term2));
	}

	public void testTheSameSymbol(){
		ExpressionParser parser = new ExpressionParser();
			
		Term term1 = parser.parseText( "x" );
		Term term2 = parser.parseText( "x" );
		assertTrue(term1.isTheSame(term2));
	}

	public void testTheSameMulti(){
		ExpressionParser parser = new ExpressionParser();
			
		Term term1 = parser.parseText( "x*y" );
		Term term2 = parser.parseText( "y*x" );
		assertTrue(term1.isTheSame(term2));
	}

	public void testTheSameFraction(){
		ExpressionParser parser = new ExpressionParser();
			
		Term term1 = parser.parseText( "x/y" );
		Term term2 = parser.parseText( "x/y" );
		assertTrue(term1.isTheSame(term2));
	}

	public void testTheSameExponentiation(){
		ExpressionParser parser = new ExpressionParser();
			
		Term term1 = parser.parseText( "x^y" );
		Term term2 = parser.parseText( "x^y" );
		assertTrue(term1.isTheSame(term2));
	}

	public void testCopyNumeric(){
		ExpressionParser parser = new ExpressionParser();
			
		Term term = parser.parseText( "2" );
		assertTrue(term.isTheSame(term.copy()));
	}

	public void testCopySymbol(){
		ExpressionParser parser = new ExpressionParser();
			
		Term term = parser.parseText( "x" );
		assertTrue(term.isTheSame(term.copy()));
	}

	public void testCopySum(){
		ExpressionParser parser = new ExpressionParser();
			
		Term term = parser.parseText( "2+x" );
		assertTrue(term.isTheSame(term.copy()));
	}

	public void testCopyProduct(){
		ExpressionParser parser = new ExpressionParser();
			
		Term term = parser.parseText( "2*x" );
		assertTrue(term.isTheSame(term.copy()));
	}

	public void testCopyFraction(){
		ExpressionParser parser = new ExpressionParser();
			
		Term term = parser.parseText( "2/x" );
		assertTrue(term.isTheSame(term.copy()));
	}

	public void testCopyExponentiation(){
		ExpressionParser parser = new ExpressionParser();
			
		Term term = parser.parseText( "2^x" );
		assertTrue(term.isTheSame(term.copy()));
	}

}
